/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ru.jSky.factory;

import java.util.ArrayList;
import java.util.Collection;
import ru.jSky.CompositeMod;
import ru.jSky.support.GrupTypeBuilder;
import ru.jSky.JSkyGlobal;
import ru.jSky.ModImporter;
import ru.jSky.finder.FinderByFormId;
import ru.jSky.finder.FromModByFormIdFinder;
import ru.jSky.interfaces.Armor;
import ru.jSky.interfaces.Enchantment;
import ru.jSky.interfaces.FormList;
import ru.jSky.interfaces.JSkyMod;
import ru.jSky.interfaces.Keyword;
import ru.jSky.interfaces.LeveledItemList;
import ru.jSky.interfaces.Major;
import skyproc.FormID;
import skyproc.GRUP_TYPE;

/**
 *
 * @author Rakev
 */
public class FinderByFormIdFactory {
    
    public FinderByFormId<Major> createMajorFinder() {
        GrupTypeBuilder grupTypeBuilder = new GrupTypeBuilder().ALL();
        GRUP_TYPE[] lookingGrups = grupTypeBuilder.build();
        return new FromModByFormIdFinder<>(getLookingMod(), lookingGrups);
    }

    public FinderByFormId<Keyword> createKeywordFinder() {
        return new FromModByFormIdFinder<>(getLookingMod(), GRUP_TYPE.KYWD);
    }

    public FinderByFormId<FormList> createFormListFinder() {
        return new FromModByFormIdFinder<>(getLookingMod(), GRUP_TYPE.FLST);
    }

    public FinderByFormId<Armor> createArmorFinder() {
        return new FromModByFormIdFinder<>(getLookingMod(), GRUP_TYPE.ARMO);
    }

    public FinderByFormId<Enchantment> createEnchantmentFinder() {
        return new FromModByFormIdFinder<>(getLookingMod(), GRUP_TYPE.ENCH);
    }

    public FinderByFormId<LeveledItemList> createLeveledListFinder() {
        return new FromModByFormIdFinder<>(getLookingMod(), GRUP_TYPE.LVLI);
    }

    private JSkyMod getLookingMod() {
        Collection<JSkyMod> importedMods = ModImporter.getInstance().getImportedMods();
        Collection<JSkyMod> lookingMods = new ArrayList<>(importedMods);
        lookingMods.add(JSkyGlobal.getInstance().getEditingMod());
        return new CompositeMod(lookingMods);
    }
}
